import { setToken, http, clearToken } from '@/utils';
export const login = (mobile, code) => {
  return async (dispatch) => {
    // 发请求
    const res = await http.post(
      '/authorizations',
      {
        mobile,
        code,
      }
    );
    dispatch({
      type: 'login/token',
      payload: res.data.data.token
    })
    setToken(res.data.data.token)
  }
}

export const logout = () => {
  return (dispatch) => {
    clearToken()
    dispatch({ type: 'login/logout' })
    dispatch({ type: 'user/clearInfo' })
  }
}